#!/bin/sh

csid=$1

if [ -z "$isrestore" ] || [ "$isrestore" != "true" ]; then
    oratab=/etc/oratab
    oratabtmp=/etc/oratab.tmp

    user=`ps -ef | grep ora_pmon | grep -v "grep" | head -n1 | sed -e 's/^[ \t]*//' | cut -d" " -f1`
    if [ -z "$user" ];then
        user=`ls -l $oratab | awk '{print $3}'`
    fi
    if [ -z "$user" ];then
        user=oracle
    fi
    grp=`ls -l $oratab | awk '{print $4}'`

    grep -ivw "$csid" "$oratab" > "$oratabtmp" && mv "$oratabtmp" "$oratab"

    chown $user:$grp $oratab
    chmod 664 $oratab
fi

exit 0
